package chapter6;
/****************************************************************
 * Author：icynlau
 * Description: 统计双色子游戏10000次内赢的次数
 * Date:2021/4/6
 * ***************************************************************
 */
public class exc6_32 {
	
	public static void main(String[] args) {
		
		System.out.print("win "+statistics(10000)+" times");

	}
	
	public static int craps() {
		
		int dice1=(int)(Math.random()*6+1);
		int dice2=(int)(Math.random()*6+1);
//		System.out.printf("You rooled %d+%d=%d\n",dice1,dice2,dice1+dice2);
		
		return dice1+dice2;
	}
	
	public static int statistics(int n) {
		
		int sum=0;		//赢的次数
		
		
		
		for(int i=0;i<n;i++) {
			
			int tmp=craps();
			
			if(tmp==2||tmp==3||tmp==12) {
				
			}else if(tmp==7||tmp==11) {
				sum++;
			}else {
				//4 5 6 8 9 10
				
				int last=0;
				
				do {
					
					last=tmp;
//					System.out.printf("point is %d\n",last);
					tmp=craps();
					
				}while(tmp!=last && tmp!=7);
				
				if(tmp==last&&tmp!=7) {
					
					sum++;
					
				}else {
					//7
					
				}
			}
			
		}
		
		return sum;
		
	}

}
